package agency.tango.materialintro.slice;

import ohos.agp.components.Checkbox;
import ohos.agp.components.Component;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.NestedScrollView;
import ohos.agp.utils.Color;
import ohos.app.Context;

import agency.tango.materialintro.ResourceTable;
import agency.tango.materialintroscreen.SlideComponentContainer;
import agency.tango.materialintroscreen.utils.ElementUtil;


/**
 * @ProjectName: material-intro-screen-master
 * @Package: agency.tango.materialintro.slice
 * @ClassName: CustomSlide
 * @Description: pageslider第3页
 * @CreateDate: 2021/4/12 14:34
 * @UpdateDate: 2021/4/12 14:34
 * @UpdateRemark: 暂无
 * @Version: 1.0
 */

public class CustomSlide extends SlideComponentContainer {
    private Checkbox checkBox;

    public CustomSlide(Context context) {
        super(context);
    }

    @Override
    protected void initView() {
        if (mContext == null || mContext.get() == null) {
            return;
        }
        mRootView =
                LayoutScatter.getInstance(mContext.get()).parse(ResourceTable.Layout_slide_custom,
                        null, false);
        if (mRootView == null) {
            return;
        }
        checkBox =
                (Checkbox) mRootView.findComponentById(ResourceTable.Id_checkBox);
        NestedScrollView mScrollview =
                (NestedScrollView) mRootView.findComponentById(ResourceTable.Id_nsv);
        mScrollview.setScrollbarColor(new Color(ElementUtil.getColor(getContext(),
                ResourceTable.Color_scroll_bar_color))); // 设置滚动条颜色
        mScrollview.setScrollbarOverlapEnabled(true); // 设置滚动条是否与内容重叠
        mScrollview.enableScrollBar(AXIS_Y, true); // 设置滚动控件竖直方向滚动
        mScrollview.enableFadeEffect(Component.FadeEffectEnum.FADEEFFECT_SCROLLBAR);
        // 设置当组件不滚动时是否隐藏滚动条
        mScrollview.setScrollbarFadingDuration(500); // 设置滚动条的淡入淡出时间
        mScrollview.setScrollbarRoundRect(true); // 设置滚动条的形状-是否为圆形
    }

    @Override
    public int backgroundColor() {
        return ResourceTable.Color_custom_slide_background;
    }

    @Override
    public int buttonsColor() {
        return ResourceTable.Color_custom_slide_buttons;
    }

    @Override
    public boolean canMoveFurther() {
        return checkBox.isChecked();
    }

    @Override
    public String cantMoveFurtherErrorMessage() {
        return getContext().getString(ResourceTable.String_error_message);
    }


}
